/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoopp.framework;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Set;

final class b {
    private final String b = "*^*";
    private final String c = "@_@";
    private File d = null;
    private final String e = "FileManager";

    public b(a parama, String paramString1, String paramString2) {
        LogUtil.w("FileManager", "FileManager, enter FileManager.");
        LogUtil.w("FileManager", "FileManager, path is : " + paramString1);
        LogUtil.w("FileManager", "FileManager, name is : " + paramString2);
        parama = null;
        if (paramString1 != null)
            parama = new File(paramString1);
        if ((parama != null) && (!(parama.exists())))
            parama.mkdirs();
        this.d = new File(paramString1 + paramString2);
        if (this.d.exists())
            return;
        try {
            this.d.createNewFile();
            LogUtil.w("FileManager", "FileManager, createNewFile success.");
            if (((parama = this).d != null) && (parama.d.isFile()) && (parama.d.exists())) {
                paramString1 = new StringBuilder();
                long l = System.currentTimeMillis();
                paramString2 = new Date(l);
                if ((paramString2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(paramString2)) != null) {
                    paramString1.append("FILE_CREATE_TIME");
                    paramString1.append(paramString2);
                    paramString1.append("*^*");
                }
                if ((paramString2 = Long.toString(l)) != null) {
                    paramString1.append("FILE_CREATE_SECONDS");
                    paramString1.append(paramString2);
                    paramString1.append("*^*");
                }
                paramString1.append("\n");
                try {
                    (parama = new OutputStreamWriter(new FileOutputStream(parama.d), "UTF-8")).write(paramString1
                            .toString());
                    parama.close();
                    LogUtil.w("FileManager", "createHeader success.");
                    return;
                } catch (Exception localException) {
                    localException.printStackTrace();
                    return;
                }
            }
            LogUtil.w("FileManager", "createHeader, mFile is null or can't write!");
            return;
        } catch (IOException localIOException) {
            localIOException.printStackTrace();
        }
    }

    public final boolean a(String paramString, HashMap paramHashMap) {
        if ((paramString != null) && (this.d != null) && (this.d.isFile()) && (this.d.exists())) {
            StringBuilder localStringBuilder = new StringBuilder();
            long l = System.currentTimeMillis();
            Object localObject3 = new Date(l);
            if ((localObject3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format((Date) localObject3)) != null) {
                localStringBuilder.append("LOG_CREATE_TIME");
                localStringBuilder.append((String) localObject3);
                localStringBuilder.append("*^*");
            }
            Object localObject1;
            if ((localObject1 = Long.toString(l)) != null) {
                localStringBuilder.append("LOG_CREATE_SECONDS");
                localStringBuilder.append((String) localObject1);
                localStringBuilder.append("*^*");
            }
            if (paramHashMap != null) {
                localObject1 = paramHashMap.keySet().iterator();
                while (((Iterator) localObject1).hasNext()) {
                    Object localObject2;
                    if ((localObject2 = ((Iterator) localObject1).next()).toString().equals("seckey="))
                        continue;
                    localStringBuilder.append(localObject2);
                    localStringBuilder.append((String) paramHashMap.get(localObject2));
                    localStringBuilder.append("*^*");
                }
            }
            localStringBuilder.append(paramString.replace("\n", "@_@"));
            localStringBuilder.append("*^*");
            localStringBuilder.append("\n");
            try {
                (localObject1 = new OutputStreamWriter(new FileOutputStream(this.d, true), "UTF-8"))
                        .write(localStringBuilder.toString());
                ((OutputStreamWriter) localObject1).close();
                LogUtil.w("FileManager", "dumpSingleLine success.");
                return true;
            } catch (Exception localException) {
                localException.printStackTrace();
                return false;
            }
        }
        LogUtil.w("FileManager", "dumpSingleLine, mFile is null or can't write!");
        return false;
    }
}